﻿using King.Box.AdminWeb.Filter;
using King.Box.AdminWeb.Logic;
using King.Box.Utils.Global;
using King.Box.Utils.Utils;
using PsCat.Aspet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace King.Box.AdminWeb.Controllers
{
    public class HomeController : Controller
    {
        private HomeService _homeService;
        public HomeController()
        {
            _homeService = new HomeService();
        }

        [Login]
        [UrlCat]
        public ActionResult Index()
        {
            return View();
        }

        [UrlCat]
        [HttpGet]
        public ActionResult Login()
        {
            return View();
        }

        [Login]
        [UrlCat]
        [HttpGet]
        public ActionResult DashBoard()
        {
            return View();
        }

        [UrlCat]
        [HttpPost]
        public JsonResult Login(string userName, string password)
        {
            return Json(_homeService.Login(userName, password));
        }

        [Login]
        [UrlCat]
        [HttpGet]
        public ActionResult LogOut()
        {
            _homeService.LogOut();
            return RedirectToAction("Login");
        }

        [HttpGet]
        [UrlCat]
        public ActionResult Error500()
        {
            return View();
        }

        [HttpGet]
        [UrlCat]
        public ActionResult Error404()
        {
            return View();
        }
    }
}